package com.mesd.killer;

import javax.swing.JFrame;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

import com.mesd.killer.model.GameResult;

//VS4E -- DO NOT REMOVE THIS LINE!
public class DetailGame extends JFrame {

	private static final long serialVersionUID = 1L;
	private GameMainUI mainUI;
	private GameResult gameResult;
	
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	
	public DetailGame(GameResult gameResult) {
		this.gameResult = gameResult;
		initComponents();
		initUI();
	}
	
	public void initUI()
	{
		installLnF();
		setTitle("DetailGame");
		getContentPane().setPreferredSize(getSize());
		pack();
		setLocationRelativeTo(null);
		setVisible(true);
	}
	
	public GameMainUI getMainUI()
	{
		if(mainUI == null)
		{
			mainUI = new GameMainUI(gameResult);
		}
		
		return mainUI;
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getMainUI(), new Constraints(new Leading(0, 1269, 10, 10), new Leading(0, 10, 10)));
		setSize(1279, 670);
	}

	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}
	
	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
//	public static void main(String[] args) {
//		installLnF();
//		SwingUtilities.invokeLater(new Runnable() {
//			@Override
//			public void run() {
//				DetailGame frame = new DetailGame();
//			}
//		});
//	}
}
